//LiuZh 2017-06-22
import React, {Component} from 'react';

import {
    View,
    Image,
    StyleSheet,
    TouchableWithoutFeedback,
} from 'react-native';

import {
    TabNavigator,
    StackNavigator,
    TabBarBottom,
} from 'react-navigation';

import MainNav from './home/page.nav.main';
import QunliaoNavScene from './qunliao/page.nav.qunliao';
import MineNav from './mine/page.nav.mine';
import DongtaiNavScene from './dong-tai/page.nav.dongtai';
import MessageNavScene from './message/page.nav.message';
import Util from '../../../core/utils/util';
import Color from '../../../core/constant/color';

import InitDB from '../../../core/database/init-db';
import FabuNav from './fabu/page.nav.fabu';
import UserScene from '../../../core/scene/page.user';
import LoginScene from '../../../core/scene/page.login';
import Toolbar from '../../../core/component/comp.toolbar';
import MainScene from './home/page.main';
import YuanwangScene from './yuanwang/page.yuanwang';
import YuanwangNavScene from './yuanwang/page.nav.yuanwang';


const TabNav = TabNavigator({
    主页: {
        screen: MainNav,
        navigationOptions: {
            tabBarIcon: ({focused, tintColor}) => (
                <Image
                    resizeMode={'contain'}
                    source={focused ? require('../images/home/tab_home_ico.png') : require('../images/home/tab_home.png')}
                    style={styles.tabImg}/>
            ),
            tabBarLabel: '主页',
            title: '主页',
        },
    },
    // 邀约: {
    //     screen: YuanwangNavScene,
    //     navigationOptions: {
    //         tabBarIcon: ({focused, tintColor}) => (
    //             <Image
    //                 resizeMode={'contain'}
    //                 source={focused ? require('../../../img/icon_tab_menu_found_active.png') : require('../../../img/icon_tab_menu_found.png')}
    //                 style={styles.tabImg}/>
    //         ),
    //         tabBarLabel: '邀约',
    //         title: '邀约',
    //     },
    // },
    动态: {
        screen: DongtaiNavScene,
        navigationOptions: {
            tabBarIcon: ({focused, tintColor}) => (
                <Image
                    resizeMode={'contain'}
                    source={focused ? require('../images/home/tab_dongtai_on.png') : require('../images/home/tab_dongtai_ico.png')}
                    style={styles.tabImg}/>
            ),
            title: '动态',
            tabBarLabel: '动态',
        },
    },

    // 发布: {
    //     screen: FabuNav,
    //     navigationOptions: {
    //         tabBarIcon: ({focused, tintColor}) => (
    //             <Image
    //                 resizeMode={'contain'}
    //                 source={focused ? require('../../../img/icon_tab_menu_publish_active.png') : require('../../../img/icon_tab_menu_publish.png')}
    //                 style={styles.tabPublish}/>
    //         ),
    //     },
    // },
    消息: {
        screen: QunliaoNavScene,
        navigationOptions: {
            tabBarIcon: ({focused, tintColor}) => (
                <Image
                    resizeMode={'contain'}
                    source={focused ? require('../images/home/tab_mesg_on.png') : require('../images/home/tab_mesg_ico.png')}
                    style={styles.tabImg}/>
            ),
        },
    },
    我的: {
        screen: MineNav,
        navigationOptions: {
            tabBarIcon: ({focused, tintColor}) => (
                <Image
                    resizeMode={'contain'}
                    source={focused ? require('../images/home/tab_my_on.png') : require('../images/home/tab_my_ico.png')}
                    style={styles.tabImg}/>
            ),
        },
    }
    /*,

    抽奖: {
        screen: LottoScene,
        navigationOptions: {
            tabBarIcon: ({focused, tintColor}) => (
                <Image
                    resizeMode={'contain'}
                    source={img}
                    style={styles.tabImg}/>
            ),
        },
    },
    */
}, {
    lazy: true,
    initialRouteName: '主页',
    tabBarPosition: 'bottom',//tabbar放在底部
    swipeEnabled: false,//不能滑动切换
    animationEnabled: false,//不要切换动画
    tabBarComponent: (props) => {
        return (
            <TabBarBottom
                {...props}
                getLabel={
                    (item)=>{
                        if(item.route.routeName=="发布"){
                            return null;
                        }
                        return item.route.routeName
                    }
                }
            />
        );
    },
    tabBarOptions: {
        style: {
            height: 58,
            borderTopWidth: Util.getRealPixel(1),
            borderColor: '#B2B2B2',
            backgroundColor: '#F9F9F9',
        },
        showLabel: true,//显示文字

        showIcon: true,//显示icon
        indicatorStyle: {
            height: 0,
        },
        tabStyle: {
            justifyContent: 'center',
            alignItems: 'center',
        },
        activeTintColor: Color.PRIMARY_COLOR,
        tintColor:'#949494',
        labelStyle: {
            fontSize: 10,
            paddingBottom:4,
        },
    }
});

const styles = StyleSheet.create({
    tabImg: {
        flex: 1,
    },
    tabPublish:{
        width:50,
        height:50,
    },
});

module.exports = TabNav;
export default TabNav;






